home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
handlers
/
example4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
4KB
|
126 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) Amiga C Club (ACC) */
/* -------------------------- ------------------ */
/* */
/* Manual: AmigaDOS Amiga C Club */
/* Chapter: Handlers Tulevagen 22 */
/* File: Example4.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 93-03-16 */
/* Version: 1.1 */
/* */
/* Copyright 1993, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to use the Speaker ("SPEAK:") */
/* handler. We will simply open the Speaker handler and set */
/* the speed to be very slow. Then we send some text to the */
/* handler and it will automatically be translated and read */
/* out loud for us. */
/* */
/* Yes, it was very late when I wrote this example... */
/* Include the dos library definitions: */
#include <dos/dos.h>
/* Now we include the necessary function prototype files: */
#include <clib/dos_protos.h> /* General dos functions... */
#include <clib/exec_protos.h> /* System functions... */
#include <stdio.h> /* Std functions [printf()...] */
#include <stdlib.h> /* Std functions [exit()...] */
#include <string.h> /* Std functions [strlen()...] */
/* Set name and version number: */
UBYTE *version = "$VER: AmigaDOS/Handlers/Example4 1.1";
/* Declared our own function(s): */
/* Our main function: */
int main( int argc, char *argv[] );
/* Main function: */
int main( int argc, char *argv[] )
{
/* Here is the text we want the Amiga to read: */
UBYTE *my_text = "I am very tired.";
/* A "BCPL" pointer to our Speaker handler: */
BPTR my_translator;
/* Store here the number of characters actually spoken: */
long characters_spoken;
/* We will now open the Speaker handler ("SPEAK:"). Any data */
/* which is send to this handler will be translated and then */
/* read out loud. Please note that you can of course only */
/* send data to the Speaker handler, not read. */
/* */
/* The Speaker handler accepts some useful options: */
/* /n Speak with a natural voice */
/* /m Speak with a man voice */
/* /f Speak with a "female" voice */
/* /r Speak like a robot with a monototonous voice */
/* /sXXX Speed, 40 - 400 */
/* /pXXX Pitch, 65 - 320 */
/* */
/* Open the Speaker handler, use natural voice with very */
/* slow speed: */
my_translator =
Open( "SPEAK:OPT/n/s40", MODE_NEWFILE );
/* Have we opened the Speaker handler successfully? */
if( my_translator == NULL )
{
/* Problems, inform the user: */
printf( "Error! Could not open the Speaker handler!\n" );
/* Exit with an error code: */
exit( 20 );
}
/* "Read" one line: (Note that with "read" I mean read */
/* like "speaking", and not like collecting data.) */
characters_spoken =
Write( my_translator, my_text, strlen( my_text ) );
/* Was the whole line "read": */
if( characters_spoken != strlen( my_text ) )
{
/* No! We could not "read" the whole line! */
printf( "Error! Could not \"read\" all text!\n" );
/* Close the Speaker handler: */
Close( my_translator );
/* Exit with an error code: */
exit( 21 );
}
/* Close the Speaker handler: */
Close( my_translator );
/* The End! */
exit( 0 );
}